The Navigator (Nav2): How Do I Get There?
The Costmap: A Robot's Safety Grid
Before a robot can navigate, it needs to understand which areas are safe and which are dangerous. This is where the "Costmap" comes in—a grid-based representation of the environment where:
- White areas represent safe, traversable space
- Red areas represent obstacles and danger zones
- Lighter red areas might represent uncertain or risky terrain
- Black areas represent unknown space that hasn't been explored yet
Think of it as a heat map for navigation safety. The robot uses this costmap to plan routes that avoid obstacles and risky areas, like a hiker choosing a path to avoid steep cliffs and dense forests.
Global Planner: The Long-Term Strategy
The Global Planner is like Google Maps for robots—it plans the main route from the starting point to the destination. It takes the costmap and figures out the most efficient, safe path across the entire area.
The global planner:
- Looks at the big picture of the environment
- Plans the overall route, accounting for known obstacles
- Creates a sequence of waypoints to follow
- Updates the plan if the destination changes
This is the "think ahead" part of navigation, where the robot decides on the general path to take.
Local Planner: The Reflexive Navigator
While the Global Planner handles the long-term route, the Local Planner handles immediate decisions—like your reflexes when you suddenly see an obstacle in your path. The Local Planner operates in real-time and can:
- Deviate from the global path to avoid sudden obstacles
- Handle dynamic obstacles like people or moving objects
- Make micro-adjustments that keep the robot safe and on course
- React quickly to situations the Global Planner didn't anticipate
This is the "react now" part of navigation, providing the agility needed to handle unexpected situations.
The Navigation Process
[DIAGRAM: 2D Costmap diagram showing a path around a box - displaying a 2D grid with obstacles marked in red, free space in white, a robot position marked with an arrow, and a goal position marked with a flag. A global path is shown as a dotted line going around an obstacle box, while the local path is shown as a solid line showing the robot's actual movement with small deviations from the global path to avoid temporary obstacles]
The navigation system works as a team:
- The costmap provides the safety information
- The Global Planner creates the main route
- The Local Planner adjusts the path in real-time
- The robot follows the combined plan to reach its destination
Key Takeaway
Navigation in robots uses both strategic planning (Global Planner) and reflexive responses (Local Planner), guided by a Costmap that shows safe vs. dangerous areas. This two-level approach allows robots to plan efficient routes while staying safe and adapting to unexpected obstacles.